TaiShouFuScene={}
local NodeID = {HeadBk=1001, UpCost=1002}

TaiShouFuScene.getNode = function()
  --if TaiShouFuScene.node==nil then
  TaiShouFuScene.node = CCBReader:load("TaiShouFuUI.ccbi")
  --end
  TaiShouFuScene.setHeadImg("hero66head.png")
  
  local label = TaiShouFuScene.node:getChildByTagExt(NodeID.UpCost, "CCLabelTTF")
  label:setString("1001")
  label:setColor(ccc3(255,0,0))

  return TaiShouFuScene.node
end

TaiShouFuScene.setHeadImg = function(imgname)
  local sp = CCSprite:create(imgname)
  local bksp = TaiShouFuScene.node:getChildByTag(NodeID.HeadBk)
  print("bksp", bksp)
  local x,y = bksp:getPosition()
  sp:setPosition(x,y)
  TaiShouFuScene.node:addChild(sp)
end
--[[
local v = TaiShouFuScene:new()
print(v.node)
v:init()
print(v.node)
v:load()
--]]

require "json"

TaiShouFuConfig={}

TaiShouFuConfig.getConfig = function(self, level)
  if TaiShouFuConfig.configs == nil then
    print("load config")
    TaiShouFuConfig:loadData()
  end
  local res = TaiShouFuConfig.configs[level]
  local tmp={}
  tmp.level=level
  tmp.upgradeCash=res[2]
  tmp.playerLevel=res[3]
  tmp.upgradeCD=res[4]
  tmp.gainCach=res[5]
  tmp.gainCD=res[6]
  return tmp
  --for k,v in pairs(res) do
  --  print(k,v)
  --end
end

TaiShouFuConfig.loadData = function()
  res = json.decode("[[1,823,1,2,600,600],[2,934,1,4,792,600],[3,1020,1,7,1080,600],[4,1087,1,10,1464,600],[5,1145,1,12,1944,600],[6,1200,1,15,2520,600],[7,1261,1,18,3192,600],[8,1336,1,21,3960,600],[9,1432,1,24,4824,600],[10,1558,11,27,5784,600],[11,1721,12,30,6840,600],[12,1929,13,33,7992,600],[13,2191,14,36,9240,600],[14,2513,15,39,10584,600],[15,2905,16,42,12024,600],[16,3373,17,45,13560,600],[17,3926,18,48,15192,600],[18,4572,19,51,16920,600],[19,5319,20,54,18744,600],[20,6174,21,57,20664,600],[21,7145,22,150,22680,600],[22,8241,23,300,24792,600],[23,9468,24,750,27000,600],[24,10836,25,1000,29304,600],[25,12352,26,1429,31704,600],[26,14024,27,1672,34200,600],[27,15859,28,1933,36792,600],[28,17867,29,2213,39480,600],[29,20053,30,2511,42264,600],[30,22428,31,2829,45144,600],[31,24998,32,3165,48120,600],[32,27771,33,3520,51192,600],[33,30755,34,3914,54360,600],[34,33958,35,4329,57624,600],[35,37389,36,5197,60984,600],[36,41054,37,5692,64440,600],[37,44962,38,6210,67992,600],[38,49121,39,6748,71640,600],[39,53539,40,7309,75384,600],[40,58223,41,7891,79224,600],[41,63181,42,8494,83160,600],[42,68422,43,9120,87192,600],[43,73953,44,9802,91320,600],[44,79782,45,10507,95544,600],[45,85918,46,12171,99864,600],[46,92367,47,12984,104280,600],[47,99138,48,13822,108792,600],[48,106239,49,14684,113400,600],[49,113677,50,15572,118104,600],[50,121461,51,16484,122904,600],[51,129598,52,17420,127800,600],[52,138097,53,18382,132792,600],[53,146965,54,19419,137880,600],[54,156210,55,20482,143064,600],[55,165841,56,23231,148344,600],[56,175864,57,24432,153720,600],[57,186288,58,25662,159192,600],[58,197121,59,26919,164760,600],[59,208371,60,28204,170424,600],[60,220045,61,29517,176184,600],[61,232151,62,30858,182040,600],[62,244698,63,32228,187992,600],[63,257694,64,33694,194040,600],[64,271145,65,35190,200184,600],[65,285061,66,39338,206424,600],[66,299448,67,41004,212760,600],[67,314316,68,42701,219192,600],[68,329671,69,44430,225720,600],[69,345522,70,46190,232344,600],[70,361876,71,47982,239064,600],[71,378742,72,49805,245880,600],[72,396128,73,51660,252792,600],[73,414041,74,53635,259800,600],[74,432489,75,55644,266904,600],[75,451480,76,61531,274104,600],[76,471022,77,63744,281400,600],[77,491123,78,65992,288792,600],[78,511791,79,68275,296280,600],[79,533033,80,70593,303864,600],[80,554859,81,72947,311544,600],[81,577274,82,75336,319320,600],[82,600289,83,77760,327192,600],[83,623909,84,80330,335160,600],[84,648144,85,82937,343224,600],[85,673001,86,90930,351384,600],[86,698488,87,93778,359640,600],[87,724612,88,96666,367992,600],[88,751383,89,99592,376440,600],[89,778808,90,102558,384984,600],[90,806894,91,105563,393624,600],[91,835649,92,108607,402360,600],[92,865083,93,111690,411192,600],[93,895201,94,114947,420120,600],[94,926013,95,118245,429144,600],[95,957526,96,128736,438264,600],[96,989748,97,132314,447480,600],[97,1022687,98,135936,456792,600],[98,1056350,99,139600,466200,600],[99,1090747,100,143308,475704,600]]")
  TaiShouFuConfig.configs = res
  --[[
  print(res)
  print(#res)
  for i=0,#res,1 do
    print(i)
  end]]
  --for key, value in pairs(result) do
  --  print(key)
  --  print(value)   
end

--TaiShouFuConfig:loadData()
local res=TaiShouFuConfig:getConfig(33)
for k,v in pairs(res) do
  print(k,v)
end

local res=TaiShouFuConfig:getConfig(3)
for k,v in pairs(res) do
  print(k,v)
end


